import { Injectable } from '@nestjs/common';
import {UserEntity} from './user.entity'
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

@Injectable()
export class UserService {

    constructor(
        @InjectRepository(UserEntity)
        private readonly userRepository: Repository<UserEntity>
    ){}


    async create(): Promise<string> {
        let user = new UserEntity();
        user.name = '张三'
        user.phone = '18453530640',
        user.age = 18,
        user.gender = 0
        return this.userRepository.save(user).then(res => {
            return '新增成功'
        }).catch(err => {
            return err
        })
    }

    findAll () {
        return this.userRepository.find()
    }
}
